#ifndef	__BFX_REFUNISTRINGBUILDER_H__
#define	__BFX_REFUNISTRINGBUILDER_H__

namespace BFX
{
// This class represents a mutable uni-string. It is convenient for situations in which it is
// desirable to modify a string, perhaps by removing, replacing, or inserting characters, without
// creating a new string subsequent to each modification.
class REFUniStringBuilder : public REFObject
{
public:
	// Create a new empty string builder with the specified capacity.
	REFUniStringBuilder(int nCapacity = 16);
	// Creates a new string builder from the specified string.
	REFUniStringBuilder(const UniString& str);
	// Creates a new string builder from the specifed substring.
	REFUniStringBuilder(UCSTR psz, int nOffset, int nLength);
	virtual ~REFUniStringBuilder();

	// Sets or gets the length of the String in this buffer.
	// If length is less than the current instance, the string is truncated.
	// If length is greater than the current  instance, NULLs are appended.
	// The capacity is adjusted to be the same as the length.
	void SetLength(int nLength);
	int GetLength() const;

	UCSTR GetData() const;
	UniString ToString() const;

	// Appends a character at the end of this string builder.
	void Append(UCHAR ch, int nRepeatCount = 1);
	// Appends an array of characters at the end of this string builder.
	void Append(UCSTR psz, int nOffset, int nLength);
	// Appends a copy of this string at the end of this string builder.
	void Append(const UniString str);
	// Appends a new line.
	void AppendLine();
	// Appends a copy of string with new line.
	void AppendLine(const UniString& str);
	// Inserts a string into this string builder.
	void Insert(int nOffset, const UniString& str);
	// Removes the specified characters from this string builder.
	void Remove(int nOffset, int nLength);

private:
	UniString	m_strValue;
};

}	//	namespace BFX

#endif	//	__BFX_REFUNISTRINGBUILDER_H__
